# Maintainer: Will Sinatra <wpsinatra@gmail.com>
# Contributor: Will Sinatra <wpsinatra@gmail.com>
pkgname=ruby-simplecov
_gemname=${pkgname#ruby-}
pkgver=0.22.0
pkgrel=0
pkgdesc="Code coverage for Ruby"
url="https://rubygems.org/gems/simplecov"
arch="noarch"
license="MIT"
depends="ruby"
checkdepends="ruby-rake ruby-bundler ruby-rspec"
depends="ruby-docile ruby-simplecov-html ruby-simplecov_json_formatter"
source="$pkgname-$pkgver.tar.gz::https://github.com/simplecov-ruby/simplecov/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/$_gemname-$pkgver"
subpackages="$pkgname-doc"
options="!check" #depends on rubocop

prepare() {
	default_prepare

	sed -i '/spec.signing_key/d' $_gemname.gemspec
}

build() {
	gem build $_gemname.gemspec
}

check() {
	rake test
}

package() {
	local gemdir="$pkgdir$(ruby -e 'puts Gem.default_dir')"

	gem install --local \
		--install-dir "$gemdir" \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname

	mkdir -p "$pkgdir"/usr/share/doc/"$pkgname"/
	install -Dm644 "$builddir"/doc/*.md "$pkgdir"/usr/share/doc/"$pkgname"/

	rm -r "$gemdir"/cache \
		"$gemdir"/build_info

	cd "$gemdir/gems/$_gemname-$pkgver"
	rm -r README.md CHANGELOG.md doc

	install -Dm644 "$builddir"/LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
}

sha512sums="
ba7e1a29a219337c1e00d055408d825b20a7b81ec4768612d9d5e8a18af08d47d86a42cee78c64ae0f431196136b5dd522364882d83e5210366d8aa03d5c54b4  ruby-simplecov-0.22.0.tar.gz
"
